package com.sunjob.mroresumeproject.dao;

import com.sunjob.common.domain.mroresume.CKBus;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface CKBusMapper {

    @Select("select count(*) from ck_busresume where status=1 and types=#{types}")
    int querycount(String types);

    @Select("select checkid,fault,bustypes,management,CKstate from ck_busresume where status=1 and types=#{types}  limit #{pages},#{size}")
    List<CKBus> querycheck(int pages, int size,String types);

    @Select("select checkid,fault,bustypes,management,CKstate from ck_busresume where checkid=#{checkid} and status=1")
    @Results({
            @Result(property = "checkid",column = "checkid"),
            @Result(property = "fault",column = "fault"),
            @Result(property = "bustypes",column = "bustypes"),
            @Result(property = "management",column = "management"),
            @Result(property = "CKstate",column = "CKstate"),
    })
    List<CKBus> querycheck2(String checkid);



    @Insert("insert into ck_busresume values(checkid,types,bustypes,Use_parts,management,fault,CKstate,failreason,money,starttime,endtime,status)")
    void insertcheck(CKBus ckBus);






    @Update("update ck_busresume set types=#{types},bustypes=#{bustypes},Use_parts=#{useparts},management=#{management},fault=#{fault},CKstate=#{CKstate},failreason=#{failreason},money=#{money} where checkid=#{checkid}")
    void updatecheck(CKBus ckBus);

    @Update("update ck_busresume set status=0 where checkid=#{checkid}")
    void deletecheck(String checkid);

    @Select("select checkid,types,bustypes,Use_parts,management,fault,CKstate,failreason,money,starttime,endtime from ck_busresume where status=1 and checkid=#{checkid}")
    @Results({
            @Result(property = "checkid",column = "checkid"),
            @Result(property = "types",column = "types"),
            @Result(property = "bustypes",column = "bustypes"),
            @Result(property = "useparts",column = "Use_parts"),
            @Result(property = "management",column = "management"),
            @Result(property = "fault",column = "fault"),
            @Result(property = "CKstate",column = "CKstate"),
            @Result(property = "failreason",column = "failreason"),
            @Result(property = "money",column = "money"),
            @Result(property = "starttime",column = "starttime"),
            @Result(property = "endtime",column = "endtime")

    })
    List<CKBus> querycheckone(Long checkid);


    @Update("update ck_busresume set status=0 where checkid=#{s}")
    void deletecheckone(String s);


}
